<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="utf-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%><%@ taglib uri="http://tiles.apache.org/tags-tiles" prefix="tiles"%>
<%-- 复制该段代码，产生新的网页 writed by:zhang3 --%>
<tiles:insertDefinition name="layout">
	<tiles:putAttribute name="head">
		<style type="text/css">
.block {
	display: block;
}

.header {
	font-weight: bold;
	border-bottom: 1px solid #dddddd;
	margin-bottom: 0.2em;
}

.pan-log {
	display: none;
}
</style>
		<script type="text/javascript">
			var id;

			function selectConsultor(user) {
				helper.confirm("确认", "确定要变更该学员的咨询师为" + user.name + "?", function() {
					//var id = $(source).attr("id");
					var url = "../front/doAppointConsultor";
					$.post(url, {
						studentId : id,
						consultId : user.id
					}, function(data) {
						helper.showMsg(data, {
							successHandler : function() {
								location.reload();
							}
						});
					});
				});
			}

			function selectTutor(user) {
				helper.confirm("确认", "确定要变更该学员的指导员为" + user.name + "?", function() {
					//var id = $(source).attr("id");
					var url = "../front/doAppointTutor";
					$.post(url, {
						studentId : id,
						tutorId : user.id
					}, function(data) {
						helper.showMsg(data, {
							successHandler : function() {
								location.reload();
							}
						});
					});
				});
			}

			$(function() {
				$(".frame").frameDialog({
					width : 500,
					height : 500
				}, function(source) {
					id = $(source).attr("id");
				});

				$(".confirm").confirmDialog(function(data) {
					helper.showMsg(data, {
						okHandler : function() {
							location.reload();
						}
					});
				});

				// 查看日志详情
				$(".btn-log").toggle(function() {
					$(this).closest(".row-fluid").next(".pan-log:first").fadeIn();
				}, function() {
					$(this).closest(".row-fluid").next(".pan-log:first").fadeOut();
				});

				// 
				$(".btn-addSet").click(function() {
					var url = "setSetStudent.jsp";
					art.dialog.open(url, {
						"title" : "报名新课程",
						width : "50%",
						height : "50%",
						close : function() {
							return true;
						}
					});
				});

				$(".btn-modifyStudent").click(function() {
					var url = "modifyStudent.jsp";
					art.dialog.open(url, {
						"title" : "修改学员基础资料",
						width : "50%",
						height : "50%",
						close : function() {
							return true;
						}
					});
				});

				$(".btn-setLessonStudent").click(function() {
					var url = "setLessonStudent.jsp";
					art.dialog.open(url, {
						"title" : "选课",
						width : "50%",
						height : "50%",
						close : function() {
							return true;
						}
					});
				});

			});
		</script>
	</tiles:putAttribute>
	<tiles:putAttribute name="mainBody">
		<div class="row-fluid">
			<ul class="nav nav-pills">
				<li><a href="#">一月内在读学员</a></li>
				<li class="active"><a href="#">在读学员</a></li>
				<li><a href="#">非在读学员</a></li>
			</ul>
		</div>
		<div>每页${students.size}项，共 ${students.totalElements} 项，当前${students.number+1}/ ${students.totalPages}页</div>
		<table class="table">
			<tr>
				<th class="span1">姓名</th>
				<th class="span1">学号</th>
				<th class="span1">CC</th>
				<th class="span1">Tutor</th>
				<th class="span2">课程</th>
				<th class="span1">报名日期</th>
				<th class="span1">听课证号</th>
				<th class="span1">卡号</th>
				<th class="span1">期限</th>
				<th class="span1">开课，结课</th>
				<th class="span1">冻结</th>
			</tr>
			<s:iterator value="#students" var="student">
				<s:url namespace="/student" action="modifyStudent" id="modifyStudent">
					<s:param name="id" value="id" />
				</s:url>
				<s:url namespace="/security/user" action="selectConsultor" id="selectConsultor">
				</s:url>
				<s:url namespace="/security/user" action="selectTutor" id="selectTutor">
				</s:url>
				<s:url namespace="/finance" action="signUp" id="signUp">
					<s:param name="id" value="id" />
				</s:url>
				<s:url namespace="/log" action="viewLogByTime" id="viewLogByTime">
					<s:param name="id" value="id" />
				</s:url>
				<s:set name="size" value="courses.size" />
				<s:if test="#size == 0">
					<tr>
						<td class="span1"><a href="${viewLogByTime}">${student.name}</a> <a href="${modifyStudent}">
								<i class="icon-pencil"></i>
							</a> <a href="${signUp}">注册课程 </a></td>
						<td class="span1">${student.stuId}</td>
						<td class="span1">${student.consultor.name}<a href="${selectConsultor}" class="frame" id="${student.id}">
								<i class="icon-pencil"></i>
							</a></td>
						<td class="span1">${student.tutor.name}<a href="${selectTutor}" class="frame" id="${student.id}">
								<i class="icon-pencil"></i>
							</a></td>
						<td colspan="7">无注册课程</td>
					</tr>
				</s:if>
				<s:else>
					<s:iterator value="courses" var="signCourse" status="status">
						<s:url namespace="/school" action="doFreezCourse" id="freezCourse">
							<s:param name="signId" value="id"></s:param>
							<s:param name="studentid" value="student.id"></s:param>
						</s:url>
						<s:url namespace="/school" action="doResumeCourse" id="resumeCourse">
							<s:param name="signId" value="id"></s:param>
							<s:param name="studentid" value="student.id"></s:param>
						</s:url>
						<s:url namespace="/school" action="doFinishCourse" id="finishCourse">
							<s:param name="signId" value="id"></s:param>
							<s:param name="studentid" value="student.id"></s:param>
						</s:url>
						<tr>
							<s:if test="#status.first">
								<td class="span2" rowspan="<s:property value="#size"/>"><a href="${viewLogByTime}">${student.name}</a> <a href="${modifyStudent}">
										<i class="icon-pencil"></i>
									</a> <a href="${signUp}">注册课程 </a></td>
								<td class="span1" rowspan="<s:property value="#size"/>">${student.stuId}</td>
								<td class="span1" rowspan="<s:property value="#size"/>">${student.consultor.name}<a href="${selectConsultor}" class="frame" id="${student.id}">
										<i class="icon-pencil"></i>
									</a></td>
								<td class="span1" rowspan="<s:property value="#size"/>">${student.tutor.name}<a href="${selectTutor}" class="frame" id="${student.id}">
										<i class="icon-pencil"></i>
									</a></td>
							</s:if>
							<td class="span2">${signCourse.course.title}</td>
							<td class="span1">${signCourse.signTime}</td>
							<td class="span1">${signCourse.lessonCard}</td>
							<td class="span1">${signCourse.cardId}</td>
							<td class="span1">${signCourse.term}</td>
							<td class="span2"><s:date name="#signCourse.beginTime" format="yyyy-MM-dd" />,<s:date name="#signCourse.beginTime" format="yyyy-MM-dd" /></td>
							<td class="span2"><a class="confirm" href="${freezCourse}" title="冻结课程">冻结</a> <a class="confirm" href="${resumeCourse}" title="恢复课程">恢复</a> <a class="confirm"
									href="${finishCourse}" title="结课">结课</a></td>
						</tr>
					</s:iterator>
				</s:else>
			</s:iterator>
		</table>
		<jsp:include page="/components/pagination/paginations.jsp"></jsp:include>
	</tiles:putAttribute>
</tiles:insertDefinition>